package modelLayer;

import java.util.ArrayList;

public class ClassCon {
	
	private ArrayList<Class> classList;
	private static ClassCon instance;
	
	public ClassCon() {
		
		classList = new ArrayList<>();
	}
	
	public static ClassCon getInstance() {
		
		if(instance == null) {
			instance = new ClassCon();
		}
		
		return instance;
		
	}
	
	public void addClass(Class c) {
		
		classList.add(c);
	}
	
	public void deleteClass(int index) {
		
		classList.remove(index);
	}
	
	public ArrayList<Class> getAll() {
		
		return classList;
	}
	
	public Class findClassByName(String name) {
		
		boolean found = false;
		Class c = null;
		
		for(int i = 0; i < classList.size() && !found; i++) {
			
			if(name.equalsIgnoreCase(classList.get(i).getClassName())) {
				
				c = classList.get(i);
				found = true;
			}
		}
		
		return c;
	}

}
